Public Class ReporteMovimientosCaja
    Dim da As New DataAccess

    Private Sub ReporteMovimientosCaja_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.DateTimePicker1.Value = Date.Today
        Me.DateTimePicker2.Value = Date.Today

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


     

        Dim reporte As New CRMovimientoCaja
        Dim sql As String = "select mov.idContrato, p. nombre, p.apellido,  mov.importe, mov.fechaVenc, mov.fechaPagada, mov.concepto, mov.tipoMov "
        sql += "from MovimientosCuentas mov "
        sql += "inner join Recibos rec on mov.idRecibo = rec.idRecibo "
        sql += "inner join Contratos con on con.idContrato = mov.idContrato "
        sql += "inner join Personas p on con.idInquilino = p.idPersona "
        sql += "where mov.fechaPagada >= '" + Me.DateTimePicker1.Value + "' and mov.fechaPagada <= '" + Me.DateTimePicker2.Value.ToString + "'"
        If Me.RadioButton1.Checked Then
            sql += " and mov.tipoMov = 'E' or mov.tipoMov = 'C'"
        End If

        If Me.RadioButton2.Checked = True Then
            sql += " and mov.tipoMov = 'S'"
        End If

        Dim ds As New inmobiliariaDataSet
        da.cargarDataSet(sql, ds.Movimientos)

        For index As Integer = 0 To ds.Movimientos.Rows.Count - 1


            If ds.Movimientos.Rows(index).Item("tipoMov") = "S" Then
                ds.Movimientos.Rows(index).Item("importe") = ds.Movimientos.Rows(index).Item("importe") * -1
                ds.Movimientos.Rows(index).Item("tipoMov") = "Salidas"
            End If
            If ds.Movimientos.Rows(index).Item("tipoMov") = "E" Then
                ds.Movimientos.Rows(index).Item("tipoMov") = "Entradas"
            End If
            If ds.Movimientos.Rows(index).Item("tipoMov") = "C" Then
                ds.Movimientos.Rows(index).Item("tipoMov") = "Comisiones"
            End If

        Next    
        reporte.SetDataSource(ds)
        CrystalReportViewer1.ReportSource = reporte
    End Sub
End Class